package com.gitee.shigen.es.vo;

import cn.easyes.annotation.HighLight;
import cn.easyes.annotation.IndexField;
import cn.easyes.annotation.IndexName;
import cn.easyes.common.constants.Analyzer;
import cn.easyes.common.enums.FieldType;
import java.io.Serializable;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @author shigenfu
 */
@Data
@IndexName(value = "index_object")
@Accessors(chain = true)
public class IndexObject implements Comparable<IndexObject>, Serializable {

    private String id;

    @HighLight
    @IndexField(fieldType = FieldType.TEXT, analyzer = Analyzer.IK_SMART, searchAnalyzer = Analyzer.IK_MAX_WORD)
    private String title;

    @HighLight
    @IndexField(fieldType = FieldType.TEXT, analyzer = Analyzer.IK_SMART, searchAnalyzer = Analyzer.IK_MAX_WORD)
    private String keywords;

    @HighLight
    @IndexField(fieldType = FieldType.TEXT, analyzer = Analyzer.IK_SMART, searchAnalyzer = Analyzer.IK_MAX_WORD)
    private String description;

    private String postDate;

    private String url;

    private float  score;

    public IndexObject() {

    }

    @Override
    public int compareTo(IndexObject o) {
        if (this.score < o.getScore()) {
            return 1;
        } else if (this.score > o.getScore()) {
            return -1;
        }
        return 0;
    }

}
